Final Fantasy IX PSX Translation tools (NTSC-U, SLUS-01251, ...)
2010.07.06

by Kruci, tools author and technical part of Czech translation team.

RK-Translations 2010 (R@ziel & Kruci, www.rk-translations.cz)

-------------------------------------------------------------------------------


Important notes
---------------

Always do backups, something can go wrong anytime.

You need edit FF9 char table before first extract, if want do changes to it.
Because texts will be extracted with these tables, and there may be errors
if changing table after extract (bad convert during import).
(Instructions for editing .TBS tables bellow.)

Only supported version is NTSC-U (SLUS-01251, ...).
(Some data are 'hardcoded', may differ in different versions)

All files have limited size. Import keep maxsizes of files.
You are warned about unimported files.

Tools tested only under Windows XP. They can work on others Windows.
Bats files surely will not work on older Windows.


These tools do
 - extract all text/graphic for translating
 - import those modified text/graphic
 - recompute sizes in special opcodes, windows sizes in texts
 - remove some duplicates on extraction and recreate them on import
 - trying import correctly, trying not damage data which are not modified
   (trying to keep possible custom modifications)

Those tools not do/are
 - increase space for translated files
 - add new files.
 
-------------------------------------------------------------------------------

Sections:
---------
(use search function)

Basic instruction

Verify imported files

Translating movies

Translating

TBS, TBL files

Other/chaos notes

-------------------------------------------------------------------------------

Basic instruction:
------------------

(0. Edit FF9 .TBS character tables before first extract, see bellow)

1. Extract IMG files from all CD, rename them to 'FF9CD1.IMG', 'FF9CD2.IMG',...
   (use CDmage, Mode2/2352)

2. Extract 'SLUS_012.51' from first CD
   (Note: SLUS files are same on all CDs)

3. These extracted files copy to 'batsCDx\orgImg' folder
   file which must exist
   batsCDx\orgImg\FF9CD1.IMG
   batsCDx\orgImg\FF9CD2.IMG
   batsCDx\orgImg\FF9CD3.IMG
   batsCDx\orgImg\FF9CD4.IMG
   batsCDx\orgImg\SLUS_012.51

4. a) Run 'extractFromAllCDximg.bat' to extract data from all CD
      This is needed run only once to extract all needed data.
      (Note: extractAllFromAllCDximg.bat extract all data, even not need data.
      This is only needed, if you are searching for something.)
      (Note: extraction take some time and hard disc space ~2GB.)
      (Note: this not extract backgrounds)
   b) Run 'extractBackground.bat' to extract all backgrounds.
      (Note: background editing is somewhat limited)
   c) File 'import\dothers\places.txt' can be used instead of using 
      'extracted\usePlacesTxt' which are places names in separate files.
      'places.txt' are those files joined and removed duplicates.
      Use 'places.txt' or files in 'extracted\usePlacesTxt', not both.
   d) Others 'extractXYZ.bat' files was left for testing purpose. 
      Are not needed to be used. Those files are extracted in step 'a)'.
      These bat are usually useable only after running bat from step 'a)',
      because they extract only some special files (from existing files, 
      not from IMG files).

5. In folder 'extracted' are now files which are used for translation.
   (note: there are not files which we did not used. Others data are
   extracted, however not copied to 'extracted' folder)
   (Note: 'extracted' folder is supposed as 'overwrite me' folder.)

6. Copy files from 'extracted' somewhere else, do not translate them
   in 'extracted' folder. This folder is used for extraction. Data in it
   can be overwritten easily (accidentally or for testing purpose).

7. Translate extracted files, see notes in 'Translating section'
   (Note: translating takes long time.)
   (Note: make backups with timestamps during translating.)

(import)

8. a) Remove unneeded files from 'import' folder.
      (there are some default files)
   b) Copy translated data to 'import' folder.
      They must have same names and be in same folders like they were 
      in 'extracted' folder.
      (Note: 'import' folder is supposed as 'readonly' folder.)
   c) (Optional) delete files in folder 'imgNew'. Files created from import.
      Deleting them slow down import, however, there can be some bad import
      left. Deleting them is not needed, but highly recommended on serious
      import to prevent possible errors.
   (Note: there is no need import all data. Is possible import only some 
   translated data. The less you import, the smaller time it take.)

9. Run 'importFileCheck.bat' to check if all files for import are present.
   (Optional, those are files which we imported. Some don't contain text
   which need to be translated.)

10.Run 'importToAllCDximg.bat' to import files from 'import' folder.
   (Optionally run other 'importXYZ.bat', if you want only import some data.
   Bats files without 'CDX' name import to CD1.)
   (Note: import suppose, that was used extracting before import.
   Import use data extracted during extracting, without them cannot import.
   These files are 'hidden' in 'workdir' folder.)
   (Note: importing take some time)

11.a) In folder 'imgNew' is result of import.
      (result files 'ff9CD1new.img', 'ff9CD2new.img', 'SLUS_012.51', ...)
      (created on first import, next import insert to these created files,
       delete them in case of troubles (they be recreated automatically))
   b) (Optional) Verify created files (see Verify section)
   c) Import these files to correct CDs. 'SLUS_012.51' to all CDs.
      (Use CDmage for import. Use 'Import' function on files.)
   d) Import movies (see Movie section).

13.(Optional) Create PPF patches.
   (Use some tools or bats from CreatePPF folder.)
   (Note: ePSXe can use only PPF patch version 2.)

14.Test created patches/files.
   (Test that it is really working)

-------------------------------------------------------------------------------

Verify imported files (Optional)
--------------------------------

Always something can go wrong, so on final import is verify recommended.
This is almost same as extracting original files. But there are imported data
extracted instead.

1. Copy new clean 'batsCDx' (original, clean, with unextracted files),
   rename for example on 'batsCDxExtractTest'

2. Copy files created by import from 'batsCDx\imgNew'
   to 'batsCDxExtractTest\orgImg' folder. Rename them to correct names.
   ('FF9CD1.IMG', 'FF9CD2.IMG', 'FF9CD3.IMG', 'FF9CD4.IMG')
   (Note: best is get those IMG files from CD after apply of final PPF patch.)

3. a) Run 'extractFromAllCDximg.bat' to extract data from all CD
   b) Run 'extractOthersH1.bat' to extract others data correctly.
      (Some imported data from 'others' folder are shifted, thus extracting
      does not match extracting original english version.)

4. a) Extract files from 'removeNumTest.zip'
      to 'batsCDx\import' and 'batsCDxExtractTest\exported' folders.
   b) Run 'removeNumbers.bat' in both folders to remove recomputed numbers.
      Folders with 'R' on the end should be created.
      (Note: those marks are sizes, which are recomputed during import. 
      Files translated are with english text sizes, so they may differ.)

5. Compare extracted and imported data by content. If there is duplicate
   folder with 'R' on the end, compare this one instead of without 'R'.
   (compare folders 'batsCDx\import' and 'batsCDxExtractTest\exported')

6. Validating results.
   Backgrounds are not validated, due they can be hard to compare. So they
   need manual validation.
   From texts is not removed Opcode '04' due there is some text on the end.
   So if there are only changes in numbers in Opcode '04',
   then results are valid.
   (Shortly: only 'chaos' after [/O:04] can differ, all other must be same.)
   (Tim\chocablt.tim must match data, not palette.)

7. Verify 'places.txt'.
   Join all files from 'batsCDxExtractTest\extracted\usePlacesTxt'
   (you can use 'places\joinTxtToOut.bat' or some custom join).
   Use some program to sort lines and remove duplicates (PSPad).
   Use that on 'places.txt' too. And then compare those sorted files.
   All names must exist in both files (result files must be same).

-------------------------------------------------------------------------------

Translating movies
------------------

see 'importStr\!readme.txt'

Shortly:
Jpsxdec was used for extracting frames/video.
Frames with text was edited.
Video was converted to uncompressed avi.
Avi2Str was used to convert avi to str files.
Tool in 'importStr' was used to import changed frames back to BIN file.

Note:
FF9 movies are not in standard 'data' format, so cannot be extracted like 
normal files. And for this reason is importing done on BIN file.

-------------------------------------------------------------------------------

Translating
-----------

All files have limited size.
Some text have enough free space after texts/data, so they can be expanded,
but not unlimitedly.

Due limited space, some 'hacks' was done to increased data space
for some texts. Bats files which use this 'hacks' have H1 on the end.

Some duplicates was removed and are automatically created in import. 
Due that it may look like there are missing files in dlgmain folder.
(If error on unknown file, it may be error on duplicate files.)


Texts
-----

In extracted files are special marks (called opcodes). If some removed,
game can freeze. Some are only for 'decoration' purpose, those can be removed
(names, positions, tabs, ...). Some opcodes has characters after them,
they must be kept with opcode.

There is not needed edit numbers in these opcodes, they are computed
automatically on import. If you need edit those numbers for some reason,
you must turn off automatic recomputing in bat files.
Although dialog window sizes are recomputed, there is no check on window
maximum size, it not check if whole window will be visible.
(this is usually not needed.)


Special files
-------------

'import\copy'
'import\copy\modified'
(direct copy of file, no conversion)

import\copy\modified\101B_0000.0d
 - font sizes (pointers to texture, position of font [X] = X*4+12)
   (to edit this file use hexeditor which can edit "integer/data types")
   (font texture is 101b_0300.tim)


Graphic
-------

TIM files can have various content. There is ususally need keep those data.
Multipalette tims must keep all palettes, and some palettes must not
be damaged. Some editors merge colors, and destroying palette pixels orders.
(You simply will see weird graphic in game).

See "batsOthers" for .TIM tools which replace .TIM files palette.

There exist plugin for .TIM editing for Gimp, Photoshop or others tools.

"WinXP mspaint" can be used to edit BMP files with palette.
(Keep palette unchanged. Can paste from other program and palette not change.)


Background
----------

All extracted background have 18488 files and needs ~8GB space
There is possible extract only previews, but dunno how we found what we needed.
There is auto extract of imported background after import.
(because they need visual check, if its ok, due using only original palettes)
Possible we found needed based on text, which was presented in that field.
(Text has matching name to background tiles)


wplaces.txt
-----------
Characters count of text in brackets must be equal to text without brackets
(text in brackets do not have and do not need diacritic characters)
(If count not match then can be problems in PSP, Arbex, ...)


-------------------------------------------------------------------------------

TBS, TBL files:
---------------

Change of .TBS/.TBL files is optional, not required.
Should only change if need extract more or different characters.

"workdir\programs\!ff9*.tbs" are text files (can open with notepad)
which describe how convert text from "ffix strings" to "normal text".
In .TBS on left side (before "=" character) are characters from "ffix",
on right side there are characters which will be in extracted texts.

"workdir\programs\!ff9.tbl" is text file containing characters length.
Used to compute size of dialog windows.
If editing characters in .TBS, may also need edit their length in .TBL.

Same .TBS files are used for export and import, not edit it after extract
(or you must do this change also to extracted texts).

.TBS file should be changed only before export
(if value in .tbs changed after export, and present in exported texts,
must also change it in exported texts, or import may write bad value)

Different .TBS files are used for different texts types, may need edit all.
(Probably exactly same editing for all .TBS files)

Special characters "\" and "=" ("\\" is character "\", "\=" is character "=",
"\xA3" => character with hexadecimal value A3)

If need use characters unsupported by game, replace unused characters.
To find characters not used in the game search extracted texts for any value
on "right side" of .TBS file. Unused character may be replaced by own chars.
(Also may need change .TBL file and replace these character in font graphic)


-------------------------------------------------------------------------------

Other/chaos notes:
------------------

Dialog text center opcodes are not perfect (may not center so well).

"Extract" will extract original files which are then used for imports.
In case of troubles, delete whole folder and start again with clean files.

.SVF files can be used after extract to verify correct extraction.

To decrease size of texts can use one font for more characters (or char+space).

File encoding of extracted and import files must be same.

NTSC-U PSX FFIX have 2 versions, only difference noticed is change in logo.
(not tested, someone reported it to us)

